package com.zjun.config;

import com.zjun.ApplicationContextHolder;
import com.zjun.init.ApplicationContentPostProcessor;
import com.zjun.safa.FastJsonSafeMode;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

public class ApplicationBaseAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public ApplicationContextHolder applicationContextHolder(){return new ApplicationContextHolder();}

    @Bean
    @ConditionalOnMissingBean
    public ApplicationContentPostProcessor applicationContentPostProcessor(ApplicationContext applicationContext){return new ApplicationContentPostProcessor(applicationContext);}

    //只有指定framework.fastjson.safa-mode值为true时生效
    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = "framework.fastjson.safa-mode",havingValue = "true")
    public FastJsonSafeMode fastJsonSafeMode(){return new FastJsonSafeMode();}
}
